package za.co.chaotik.tron.screens;

import za.co.chaotik.tron.AbstractMap;
import za.co.chaotik.tron.CycleGame;
import za.co.chaotik.tron.ScreenTransitionGame;
import za.co.chaotik.tron.maps.RectangularMap;
import za.co.chaotik.tron.maps.SphericalMap;
import za.co.chaotik.tron.screens.renderer.MapRenderer;
import za.co.chaotik.tron.screens.renderer.RectangularMapRenderer;
import za.co.chaotik.tron.screens.renderer.SphericalMap2DRenderer;

import com.badlogic.gdx.Gdx;

public class MapScreen extends CycleGameScreen {
	private MapRenderer renderer;
	private static final String LOG = CycleGame.class.getSimpleName();
	
	public MapScreen(ScreenTransitionGame game, AbstractMap map) {
		super(game);
		
		if (map instanceof RectangularMap) {
			renderer = new RectangularMapRenderer(this);
		} else if (map instanceof SphericalMap) {
			renderer = new SphericalMap2DRenderer(this);
		}
		
		map.addObserver(renderer);
		map.changed();
	}

	@Override
	public void dispose() {
	}

	@Override
	public void render(float delta) {
		renderer.render(delta);
	}

	@Override
	public void resize(int width, int height) {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

	@Override
	public void show() {
		Gdx.app.log(LOG, "Showing map screen...");
		
		// Enable input to the map screen
		Gdx.input.setInputProcessor(renderer.getInputProcessor());
	}

	@Override
	public void hide() {
		Gdx.app.log(LOG, "Hiding map screen...");
		
		// Disable input to the map screen
		Gdx.input.setInputProcessor(renderer.getInputProcessor());
	}
}
